package com.lianyi.login.mvp.model;

import android.app.Application;

import com.google.gson.Gson;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;

import com.jess.arms.di.scope.ActivityScope;

import javax.inject.Inject;

import com.lianyi.commonsdk.http.Api;
import com.lianyi.login.mvp.contract.LoginContract;

import io.reactivex.Observable;
import okhttp3.ResponseBody;


@ActivityScope
public class LoginModel extends BaseModel implements LoginContract.Model {
    private Gson mGson;
    private Application mApplication;

    @Inject
    public LoginModel(IRepositoryManager repositoryManager, Gson gson, Application application) {
        super(repositoryManager);
        this.mGson = gson;
        this.mApplication = application;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mGson = null;
        this.mApplication = null;
    }

    @Override
    public Observable<ResponseBody> getRsa() {
        return mRepositoryManager.obtainRetrofitService(Api.class)
                .getAes();
    }

    @Override
    public Observable<ResponseBody> login(String account, String password) {
        return mRepositoryManager.obtainRetrofitService(Api.class)
                .userlogin(account, password);
    }

    @Override
    public Observable<ResponseBody> getDoctorList(int hid, String data) {
        return mRepositoryManager.obtainRetrofitService(Api.class)
                .getDoctorList(hid, data);
    }
}